# coding: utf-8
from PyQt6.QtCore import QUrl
from PyQt6.QtGui import QDesktopServices

from common import Icon
from components import TitleInterface
from .plugins.pdf import PdfToImageView, PDFToWordView


class PDFInterface(TitleInterface):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.addDefaultSampleCard(
            Icon.TRANSLATE,
            '翻译',
            '翻译 PDF 文档',
            'translate_pdf',
            clicked=lambda: QDesktopServices.openUrl(QUrl('https://app.immersivetranslate.com/file/'))
        )

        self.addSampleCard(PDFToWordView(self))
        self.addSampleCard(PdfToImageView(self))
        self.__initWidgets()

    def __initWidgets(self):
        self.setTitle('PDF 工具')
        self.setObjectName('PDFInterface')
